{extend name="index/index" /}
{block name="main"}
 <div class="content-wrapper">
      <div class="page-title">
        <div>
          <h1><i class="fa fa-th-list"></i>  用户列表</h1>
          <p>Table to display analytical data effectively</p>
        </div>
        <div>
          <ul class="breadcrumb side">
            <li><i class="fa fa-home fa-lg"></i></li>
            <li>Tables</li>
            <li class="active"><a href="#">Data Table</a></li>
          </ul>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12 pa">
        <a class='btn btn-info' href='/admin/channel/create'>新增频道</a>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-body">
              <table class="table table-hover table-bordered" id="sampleTable">
                <thead>
                  <tr>
                      <th>id</th>
                      <th>名字</th>
                      <th>区长</th>
                      <th>简介</th>
                      <th>图片</th>
                      <th>注册时间</th>
                      <th>用户数</th>
                      <th>文章数</th>
                      <th>浏览数</th>
                      <th>状态</th>
                      <th width='150'>操作</th>
                  </tr>
                </thead>
                <tbody>
                  {volist name="list" id="v"}
                    <tr class="uid{$v.id}">
                        <td>{$v.id}</td>
                        <td><strong>{$v.name}</strong></td>
                        <td>{$v.uid}</td>
                        <td>{$v.desc }</td>
                        <td class='imgurl'>{$v.img}</td>
                        <td>{$v.addtime }</td>
                        <td>{$v.users }</td>
                        <td>{$v.posts }</td>
                        <td>{$v.liulan }</td>
                        <td >
                          <div class="toggle lg">
                            <label>
                              <input type="checkbox" class='userstatus' {$v.status?'checked':''} ><span class="button-indecator"></span>
                            </label>
                          </div>
                        </td>
                      <td>
                        <a class="btn-sm btn-danger" onclick='del("{$v.id}")' ><i
                        class="fa fa-trash-o fa-fw"></i></a>
                        <a class="btn-sm btn-success" onclick='edit("{$v.id}")'><i
                        class="fa fa-edit"></i></a>
                        <a  data-toggle="tooltip" title="详情" class="btn-sm btn-info" href='/admin/channel/getinfo/id/{$v.id}'>
                          <i class="fa fa-file-text-o fa-fw"></i></a>
                      </td>
                    </tr>
                  {/volist}
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script>

    
    $(function(){
      $('.imgurl').each(function(){
      var maxwidth=10;
      if($(this).text().length>maxwidth){
      $(this).text($(this).text().substring(0,maxwidth));
      $(this).html($(this).html()+'…');
      }
      });



      


    });
    
      // 通过id删除
  function del(id){
        $.ajax({
            type: 'delete',
            url: '/admin/channel/' + id,
            dataType : 'json',
            success : function (data){
                // console.log(data);
            $('.uid'+id).empty();
            motai(data);
            },
            error : function () {
                motai('AJAX执行失败!');
            }
        });
      }


    </script>
{/block}

